package de.hauschild.gmltracer.gml.impl.value.bool;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.real.RealToken;

public abstract class TwoRealComparatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final RealToken second = tokenStack.pop(RealToken.class);
    final RealToken first = tokenStack.pop(RealToken.class);

    final Boolean result = compare(first.getValue(), second.getValue());
    tokenStack.push(new BooleanToken(result));
  }

  protected abstract boolean compare(final Double first, final Double second);

}
